/**
 * Copyright &copy; 2012-2016 <a href="https://istep.lczyfz.com">Istep</a> All rights reserved.
 */
package com.lczyfz.istep.modules.scene.service;

import com.lczyfz.istep.common.persistence.Page;
import com.lczyfz.istep.common.service.CrudService;
import com.lczyfz.istep.modules.scene.dao.SceneNetworkDao;
import com.lczyfz.istep.modules.scene.entity.SceneNetwork;
import com.lczyfz.istep.modules.scene.entity.SceneVmTemplate;
import com.lczyfz.istep.modules.sys.entity.User;
import com.lczyfz.istep.modules.sys.utils.UserUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * 网络管理Service
 * @author dh
 * @version 2017-03-20
 */
@Service
@Transactional(readOnly = true)
public class SceneNetworkService extends CrudService<SceneNetworkDao, SceneNetwork> {

	public SceneNetwork get(String id) {
		return super.get(id);
	}
	
	public List<SceneNetwork> findList(SceneNetwork sceneNetwork) {
		return super.findList(sceneNetwork);
	}
	
	public Page<SceneNetwork> findPage(Page<SceneNetwork> page, SceneNetwork sceneNetwork) {
		return super.findPage(page, sceneNetwork);
	}
	
	@Transactional(readOnly = false)
	public void save(SceneNetwork sceneNetwork) {
		super.save(sceneNetwork);
	}
	
	@Transactional(readOnly = false)
	public void delete(SceneNetwork sceneNetwork) {
		super.delete(sceneNetwork);
	}
	public List<SceneNetwork> getNetworkByName(SceneNetwork sceneNetwork)
	{
		return dao.getNetworkByName(sceneNetwork);
	}
	@Transactional(readOnly = false)
	public void insert(SceneNetwork sceneNetwork) {
		logger.debug("networkIdinsert=== [{}]", sceneNetwork.getId());

		dao.insert(sceneNetwork);
	}

	public void networkPreInsert(SceneNetwork sceneNetwork) {

		User user = UserUtils.getUser();
		if (StringUtils.isNotBlank(user.getId())) {
			sceneNetwork.setUpdateBy(user);
			sceneNetwork.setCreateBy(user);
		}
		Date date=new Date();
		sceneNetwork.setUpdateDate(date);
		sceneNetwork.setCreateDate(date);

  	}
	public List<SceneNetwork> findNetworkListByEnvironmentId(String DEL_FLAG_NORMAL,String id)
	{
		return  dao.findNetworkListByEnvironmentId(DEL_FLAG_NORMAL,id);
	}

	public List<SceneNetwork> findVmNetworkList(SceneVmTemplate sceneVmTemplate)
	{
		return  dao.findVmNetworkList(sceneVmTemplate);
	}
	public List<SceneNetwork> findEnvironmentNetworkDetail(String DEL_FLAG_NORMAL,String id)
	{
		return  dao.findEnvironmentNetworkDetail(DEL_FLAG_NORMAL, id);
	}


}